<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>维护员列表</title>
    {include file="common/linkcss" /}
</head>


<body>

    <div class="container-fluid">
        <div class="row">

            {include file="common/sidebar" /}

            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="card border-primary  ">
                    <div class="card-header">
                        <h1 class="page-header">
                            维护员列表
                        </h1>
                        <a href="{:url('add')}" class="btn btn-danger">新增维护员</a>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th scope="col">编号</th>
                                        <th scope="col">用户名</th>
                                        <th scope="col">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name="admin" id="vo"}
                                    <tr id="tr{$vo.id}">
                                        <th scope="row">{$vo.id}</th>
                                        <td>{$vo.name}</td>
                                        <td scope="row">
                                            <a href="{:url('admin/edit',array('id'=>$vo['id']))}" class="btn btn-primary btn-sm">编辑</a>
                                            {if $vo.is_admin}
                                            <button type="button" class="btn btn-secondary btn-sm">超级管理员</button>
                                            {else/}
                                            <button type="button" class="btn btn-danger btn-sm" onclick="delThis('{$vo.id}')">删除</button>
                                            {/if}
                                        </td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                        </div>

                        {$admin|raw}

                    </div>
                </div>
            </div>
            <!-- main end -->



        </div>
    </div>
    <!-- container end -->

    <script>
        function delThis($id) {
            confirm('警告', '你正在进行删除操作，一旦删除将无法挽回！', function (isConfirm) {
                if (isConfirm) {
                    $.post("{:url('admin/del')}",
                        {
                            id: $id,
                        },
                        function (data, status) {
                            if (data == 1) {
                                alert("提示!", "已成功为你删除", function () {
                                    $('#tr' + $id).remove();
                                }, {
                                    type: 'success',
                                    confirmButtonText: '确定'
                                });
                            }
                        }
                    );
                }
            }, {
                confirmButtonText: '我确定',
                cancelButtonText: '取消操作',
                width: 400
            });
        }
    </script>
</body>

</html>